[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 fclose()                Close a Stream


 #include   <stdio.h>

 int        fclose(stream);
 FILE       *stream;                     Pointer to file structure

    fclose() closes 'stream' after flushing all buffers associated with
    'stream'.  When the stream is closed, system-allocated buffers are
    automatically freed, but those assigned with setbuf() and setvbuf()
    are not.

       Returns:     0, if successful.  On error, EOF is returned.

         Notes:     Use fclose() to close a file that has been opened
                    with fopen().

   -------------------------------- Example ---------------------------------

    The following statements open and close a file.

           #include <stdio.h>

           FILE *in;

           main()
           {
               if ((in = fopen("input.dat","r+"))!= NULL) {
                   .
                   .
                   .
                   fclose(in);
               }
           }


See Also: close() fdopen() fflush() fopen() freopen()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson